package org.example.mapper;

import org.apache.ibatis.annotations.*;
import org.example.common.entity.RolePermission;

import java.util.List;

public interface RolePermissionMapper {

    // 插入角色权限
    @Insert("INSERT INTO role_permission (role_id, permission_code, permission_name, description) " +
            "VALUES (#{roleId}, #{permissionCode}, #{permissionName}, #{description})")
    void insertRolePermission(RolePermission rolePermission);

    // 查询角色的所有权限
    @Select("SELECT * FROM role_permission WHERE role_id = #{roleId}")
    List<RolePermission> getPermissionsByRoleId(@Param("roleId") Long roleId);

    // 删除角色权限
    @Delete("DELETE FROM role_permission WHERE role_id = #{roleId} AND permission_code = #{permissionCode}")
    void deleteRolePermission(@Param("roleId") Long roleId, @Param("permissionCode") String permissionCode);
}
